
// URL
/* 
*fn('http://baidu.com?a=1&b=2')得到{a: 1,b:2}
*fn(http://baidu.com, {a: 1,b:2}}得到http://baidu.com?a=1&b=2
*实现上诉功能
*/
function fn(a, obj) {
    let arr = []
    let resObj = {}
    if (arguments.length == 1) {
        arr = a.split('?')
        let newArr = arr[1].split('&')
        for (let key of newArr) {
            console.log(key)
            let resArr = key.split('=')
            resObj[resArr[0]] = Number(resArr[1])
            return resObj
            console.log(newArr)
        }
    } else {
        for (let key in obj) {
            arr.push(key + '=' + obj[key]);
        }
        return a + '?' + arr.join('&')
    }
}


